import os
import pytest
import requests

def login():
    #登录
    url=os.getenv('host') + os.getenv('login')

    #请求体
    body={
        "email":"1478997572@qq.com",
        "pwd":"eWLPHopE945d2ivttHaQTQ=="
    }

    requests1=requests.post(url=url,data=body)

    print('登录成功',requests1.json())

    userId=requests1.json()['result']['userId']
    sessionId=requests1.json()['result']['sessionId']

    return userId,sessionId

#获取登录值返回
@pytest.fixture(scope='session')
def get_login():
    data=login()

    headers={
        "userId":str(data[1]),
        "sessionId":str(data[0])
    }

    print('获取登录值',headers)

    return headers





